//
//  NewsViewController.swift
//  Weibo_SwiftDemo
//
//  Created by gjh on 2020/12/12.
//

import UIKit

class NewsViewController: JHBaseViewController {
    
    var name: String?
    var age = 0
    
    var chineseScore = 0.0
    var mathScore = 0.0
    
    var averageScore: Double {
        get {
            return (chineseScore + mathScore) / 2
        }
    }
//    private let tableView: UITableView = {
//        let tableview = UITableView(frame: CGRect(x: 0, y: 64, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height), style: .grouped)
//        return tableview
//    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        
        title = "新闻\(navigationController?.viewControllers.count ?? 0)" 
        view.backgroundColor = UIColor.lightGray
                
//        tableView.delegate = self
//        tableView.dataSource = self
//        view.addSubview(tableView)
//        
        print(FBMeUser.propertyList())
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        let httptool = HttpTool()
        httptool.requestData {
            print("请求到了网络数据")
        }
        httptool.requestData { (named) in
            print("\(named)")
        }
    }
}
extension NewsViewController {
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 30
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 30
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let ID = "cell"
        
        var cell = tableView.dequeueReusableCell(withIdentifier: ID)
        
        if cell == nil {
            cell = UITableViewCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: ID)
        }
        
        cell?.textLabel?.text = "测试数据：\(indexPath.row)"
                  
        return cell!
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print("点击了\(indexPath.row)")
        let VC = NewsViewController()
        navigationController?.pushViewController(VC, animated: true)
    }
}
